﻿namespace Homework06
{
    internal class Program
    {
        /// <summary>
        /// 输出10000以内有多少个质数
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //初始化
            int primeCount = CountPrimes(10000);
            //判断一个数是不是质数
            static bool IsPrime(int number)
            {
                if (number <= 1) return false;
                for (int i = 2; i * i <= number; i++)
                {
                    if (number % i == 0) return false;
                }
                return true;
            }
            //计算质数个数
            static int CountPrimes(int limit)
            {
                int count = 0;
                for (int i = 2; i < limit; i++)
                {
                    if (IsPrime(i))
                    {
                        count++;
                    }
                }
                return count;
            }
            Console.WriteLine($"10000以内的质数个数：{primeCount}");
        }
    }
}
